﻿export default function preSignature(url) {
  $.ajax({
    type: "GET",
    url:
      "https://www.shandong10086.com/wechatflowfruit/commonCtl/getSignature?url=" +
      encodeURIComponent(url),
    dataType: "json",
    async: false,
    success: function(data) {
      let Signature =  JSON.parse(data.data);
      wx.config({
        debug: false,
        appId: "wx43a850f87498127d",
        timestamp: Signature.timeStamp,
        nonceStr: Signature.nonceStr,
        signature: Signature.jsSignature,
        jsApiList: [
          "onMenuShareTimeline",
          "onMenuShareAppMessage",
          "onMenuShareQQ",
          "onMenuShareQZone"
        ]
      });
      wx.ready(function() {
        wx.onMenuShareTimeline({
          title: "中国移动10086服务专区", // 分享标题
          link: url, // 分享链接
          imgUrl:
            "https://www.shandong10086.com/weixin/otherSamllProject/shareIcon/wx_serverZoom.png",
          success: function() {
          },
          cancel: function() {
            // 用户取消分享后执行的回调函数
          }
        });

        wx.onMenuShareAppMessage({
          title: "中国移动10086服务专区", // 分享标题
          desc:
            "移动服务不必东奔西走，你想要的这里都有！", // 分享描述
          link: url,
          imgUrl:
            "https://www.shandong10086.com/weixin/otherSamllProject/shareIcon/wx_serverZoom.png",
          success: function() {
          },
          cancel: function() {
            // 用户取消分享后执行的回调函数
          }
        });
      });
    }
  });
}
